package com.banciyuan.bcywebview.biz.detail.image;

import android.app.Activity;
import android.content.Context;

import com.banciyuan.bcywebview.biz.write.photoselecotor.util.CommonUtils;
import com.banciyuan.bcywebview.utils.common.UIUtils;

/**
 * Created by squall on 2016/3/9.
 */
public class CommentImageTask {

    public int[] dealPic(int orgin_width, int orgin_height, Context mContext) {
        float maxWidth = UIUtils.px2dip((int) (CommonUtils.getWidthPixels((Activity) mContext) * 0.6f), mContext);
        float maxHeight = maxWidth * 0.8f;
        float ratio0 = maxWidth / 200f;
        float width = (float) orgin_width / 3;
        float height = (float) orgin_height / 3;
        float ratio = width / height;
        width = width * ratio0;
        height = height * ratio0;
        if (width > maxWidth) {
            int minus_width = (int) (width - maxWidth);
            width = maxWidth;
            height = (int) (height - minus_width * ratio);
        }
        if (height > maxHeight) {
            height = maxHeight;
        }
        return new int[]{UIUtils.dip2px((int) width, mContext), UIUtils.dip2px((int) height, mContext)};
    }
}